<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.taobao.wolfwolf.taobao.Trade"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="my" uri="http://snowsnow.taobao.com/functions"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	response.setCharacterEncoding("utf8");
	String status = request.getParameter("status");
	String url = "http://item.taobao.com/item.htm?id=";
	List<Object[]> tradeCollect = new Trade(status).getTradesCollect();
	request.setAttribute("status", status);
	request.setAttribute("url", url);
	request.getSession().setAttribute("tradeCollect", tradeCollect);
%>

<form id='form' method="get" action="servlet/ProductSchedule">
	<table class="tradeTable" align='center'>
		<tr>
			<td colspan='6'>
				<input type='checkbox' id='selectAllCheckbox' onclick='selectAll();'>选择全部
				<input type='checkbox' name='meger'>合并同类商品 
				<input type='button' id='collapseAllOrder'	onclick='collapseAll("${fn:length(tradeCollect) + 1}", true)' value='折叠全部' />
				<input type='submit' value='生成排期' />
			</td>
		</tr>
		<tr>
			<td width="10%">&nbsp;</td>
			<td width="40%" align='center'>
				<b>商品名称</b>
			</td>
			<td width="15%" align='center'>
				<b>商品分类名称</b>
			</td>
			<td width="9%" align='center'>
				<b>购买数量</b>
			</td>
			<td width="13%" align='center'>
				<b>买家留言</b>
			</td>
			<td width="13%" align='center'>
				<b>卖家备注</b>
			</td>
		</tr>
	</table>
	<br>

	<c:set var="c" value="1" />
	<c:forEach var="trade" items="${tradeCollect}">
		<table class='tradeTable' align='center'>

			<tr name='${c}'>

				<c:choose>
					<c:when test="${trade[1]}">
						<c:set var="orderTids">
				  			${my:testJstlFunction(trade[0], trade[2])}
				  		</c:set>
					</c:when>
					<c:otherwise>
						<c:set var="orderTids">
			  			${my:testJstlFunction(trade[0], null)}
			  		</c:set>
					</c:otherwise>
				</c:choose>

				<td colspan='6' style='font-size: 14px'>
					<input type='checkbox' name='tid' value='${orderTids}' />
					<input type='button' value='折叠'	id='button_${c}' onclick='expand(${c}, true)' /> 
					<c:set var='print_express' value='打印订单' />
					<c:set var='send_button_style' value='' />
					<c:set var='search_logicist_button_style' value='display:none' />
					
					<c:if test="${status == 'WAIT_BUYER_CONFIRM_GOODS'}">
						<c:set var='print_express' value='补打印订单' />
						<c:set var='send_button_style' value='' />
						<c:set var='search_logicist_button_style' value='' />
					</c:if>
					<input type='button' value='${print_express}' onclick='print(${trade[0]})' /> 
					<input type='button' value='发货' style='${send_button_style}' onclick="openUrl([${orderTids}], '${trade[4]}');" />
					<input type='button' value='查物流' style='${search_logicist_button_style}' onclick='searchLog(${trade[0]})' />
					
					订单编号：${trade[0]} <b>买家昵称: ${trade[4]} </b> <br /> 成交金额: <b style='color:red'>${trade[7]}</b> 成交时间: ${trade[8]}
				</td>
			</tr>

			<c:set var="iii" value="0" />
			<c:forEach var="order" items="${trade[3]}">
				<tr name='item${c}'>
					<td width='10%'>
					<span style="CURSOR: pointer"><img src='${order[5]}' title='${order[0]}' width='64' height='64' onclick='showPic(this);' /></span>
					</td>
					<td width='40%' class='bb'><a href='${url}${order[1]}'>${order[0]}</a></td>
					<td class='15%' width='15%'>${order[2]}</td>
					<td width='9%' align='center'>${order[4]}</td>
					<c:if test="${iii == 0}">
						<td width='13%' rowspan='${fn:length(trade[3])}'>${trade[5]}</td>
						<td width='13%' rowspan='${fn:length(trade[3])}'>${trade[6]}</td>
						<c:set var="iii" value="3" />
					</c:if>
				</tr>
			</c:forEach>

			<c:set var="c">
			${c + 1}
 			</c:set>
		</table>
		<br />
	</c:forEach>
	
	<c:if test="${c - 1 == 0 }">
		<table class='tradeTable' align='center'>
			<tr>
				<td align='center'><h1>没有订单</h1></td>
			</tr>
		</table>
	</c:if>

</form>
<h1 align='center'>订单总数: ${c - 1}</h1>